<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.*" %>
<%
	String name=(String)request.getAttribute("name");
	List stockList = (List) request.getAttribute("stockList");
	String currPage=request.getAttribute("currPage").toString();
	String pageHtml = (String)request.getAttribute("pageHtml");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题文档</title>
<link href="${pageContext.request.contextPath }/common/themes/App_Themes/default/Style.css" rel="stylesheet" type="text/css" />
 <script src="${pageContext.request.contextPath }/common/js/common.js" type="text/javascript"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath }/common/js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				$("#del").click(function(){
					var item = $(":checkbox[name='id']:checked");
					if(item.length==0){
						alert("对不起，请选择一个用户！");
						return;
					}
					$("#method").val("del");
					$("#delForm").submit();
				});
				$("#lock").click(function(){
					var item = $(":checkbox[name='id']:checked");
					if(item.length==0){
						alert("对不起，请选择一个用户！");
						return;
					}
					$("#method").val("lock");
					$("#delForm").submit();
				});
				$("#unlock").click(function(){
					var item = $(":checkbox[name='id']:checked");
					if(item.length==0){
						alert("对不起，请选择一个用户！");
						return;
					}
					$("#method").val("unlock");
					$("#delForm").submit();
				});
				$("#given").click(function(){
					var item = $(":checkbox[name='id']:checked");
					if(item.length>1){
						alert("对不起，只能选择一个用户！");
						$("input[name='id']").each(function(){this.checked=false;});
						return;
					}else if(item.length==0){
						alert("对不起，请选择一个用户！");
						return;
					}else if($("#enable"+item[0].value).val()==1){
						alert("用户被锁定，不能分配权限！");
						$("input[name='id']").each(function(){this.checked=false;});
						return;
					}else if($("#type"+item[0].value).val()==1){
						alert("管理员不需要分配权限！");
						$("input[name='id']").each(function(){this.checked=false;});
						return;
					}else if(item[0].value==$("#currUid").val()){
						alert("不能给自己分配权限！");
						$("input[name='id']").each(function(){this.checked=false;});
						return;
					}
					window.location.href="${pageContext.request.contextPath}/admin/toSetPermissionPage.do?id="+item[0].value;
				});
			});
		</script>
</head>

<body class="layout_body">
<div id="layout_container">

<div id="layout_mainContent">
    <!-- begin #layout_mainContent -->
    <!-- begin #box_table专用于grid -->
    <table   border="0" cellspacing="0" cellpadding="0" class="box_table">
      <tr>
        <td class="box_top_left_grid"></td>
        <td class="box_top_center_grid">
         <!-- 导航 -->
        <div class="box_top_center_grid_text"> 当前位置：<a href="#">首页</a> >> 系统管理 >> 用户列表</div>
        <!-- 导航 -->
        </td>
        <td class="box_top_right_grid"></td>
      </tr>
      <tr>
        <td class="box_left"></td>
        <td>

        <!-- 内嵌按钮-->
        <table class="layout_grid_function">
             <form action="${pageContext.request.contextPath}/admin/stockslistpage.do" method="post" id="queryForm" name="queryForm" ><tr><td>
         股票名：<input type="text" name="name"  class="form_query" value="<%=name %>" />
           <input type="submit" class="button_original_yellow"  value="查询"/>

          </td>
         

          </tr>
          </form>
          </table>
          <!-- 内嵌按钮-->
          <form name="frmList" method="post" id="delForm">
              
         <!--内嵌内容表格-->
         <table   border="0" cellspacing="0" cellpadding="0" class="box_table">
      <tr>
        <td class="box_top_left_content"></td>
        <td class="box_top_center_content tac">股&nbsp;&nbsp;&nbsp;&nbsp;票</td>
        <td class="box_top_right_content"></td>
      </tr>
      <tr>
        <td class="box_left_content"></td>
        <td class="tdPadding">
<!--内容-->
		<table width="100%" border="0" cellspacing="1" cellpadding="1" class="grid_table">
                <tr class="grid_table_head">
                    <td>序号</td>
                    <td>股票名称</td>
                    <td>股票代码</td>
                    <td>空开仓状态</td>
                    <td>多开仓状态</td>
                    <td>操作</td>
                </tr>
                <%
                if(stockList!=null && stockList.size()!=0){
                	
                for(int i=0;i<stockList.size();i++){
                	
                Map row = (Map)stockList.get(i);
                String id= row.get("id").toString();
                String enable= row.get("enable").toString();
                String enable2= row.get("enable2").toString();
                String stockname = (String)row.get("name");
                String code = (String)row.get("code");

                %>
                <tr>
                    <td><%=id %></td>
                    <td><%=stockname %></td>
                    <td><%=code %></td>
                    <td>
                    	<%if("1".equals(enable)){out.print("启用");}else{out.print("禁止");} %>
                    </td>
                    <td>
                    	<%if("1".equals(enable2)){out.print("启用");}else{out.print("禁止");} %>
                    </td>
                 	<td>
                 		<a href="${pageContext.request.contextPath}/admin/enableStock.do?enable=0&id=<%=id%>&name=<%=name%>&page=<%=currPage %>">空开仓禁止</a>
                 		<a href="${pageContext.request.contextPath}/admin/enableStock.do?enable=1&id=<%=id%>&name=<%=name%>&page=<%=currPage %>">空开仓启用</a>
                 		<a href="${pageContext.request.contextPath}/admin/enable2Stock.do?enable2=0&id=<%=id%>&name=<%=name%>&page=<%=currPage %>">多开仓禁止</a>
                 		<a href="${pageContext.request.contextPath}/admin/enable2Stock.do?enable2=1&id=<%=id%>&name=<%=name%>&page=<%=currPage %>">多开仓启用</a>
                 	</td>
                </tr>
                <%}}%>
</table>
<!--内容-->

        </td>
        <td class="box_right_content"></td>
      </tr>
      <tr>
        <td class="box_bottom_left_content"></td>
        <td class="box_bottom_center_content">

		<!--内嵌分页及工作流按钮-->
      <div class="layout_grid_page_workflow">

         <div class="layout_grid_page tac">
       	<%=pageHtml %>
       
         </div>
      </div>
         <!--内嵌分页按钮-->

		</td>
        <td class="box_bottom_right_content"></td>
      </tr>
    </table>
      </form>



        </td>
        <td class="box_right"></td>
      </tr>
      <tr>
        <td class="box_bottom_left"></td>
        <td class="box_bottom_center"></td>
        <td class="box_bottom_right"></td>
      </tr>
    </table>
    <!-- end #box_table -->


    <!-- end #layout_mainContent -->
</div>
</div>

</body>
</html>
<script>

    function doAction(act)
    {
        if(act=='sp'){
        frmList.act.value="sp";
        frmList.submit();
        }
        else if(act=="star"){
        frmList.act.value="star";
        frmList.submit();
        }
        else if(act=="indexstar"){
        frmList.act.value="indexstar";
        frmList.submit();

        }
    }
    $("#checkall").click( 
    		function(){ 
    		if(this.checked){ 
    		$("input[name='id']").each(function(){
        		if($(this).val()!=$("#currUid").val()){
        			this.checked=true;
        		}
        	}); 
    		}else{ 
    		$("input[name='id']").each(function(){this.checked=false;}); 
    		} 
    		} 
    		);
   
    </script>